package org.szgb.console.zx.dashboard.service;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.szgb.console.zx.dashboard.entity.ZxDashboard;
import org.szgb.console.zx.dashboard.mapper.ZxDashboardMapper;

@Slf4j
@Service
public class ZxDashboardService {
    private final ZxDashboardMapper zxDashboardMapper;

    @Autowired
    public ZxDashboardService(ZxDashboardMapper zxDashboardMapper) {
        this.zxDashboardMapper = zxDashboardMapper;
    }

    public ZxDashboard getDashboardData() {
        ZxDashboard zxDashboard = zxDashboardMapper.getCountData();
        if (zxDashboard == null) {
            zxDashboard = new ZxDashboard();
            zxDashboard.setFinishNum(0);
            zxDashboard.setWaitNum(0);
            zxDashboard.setUnfinishNum(0);
        }
        zxDashboard.setPlanTypeNumList(zxDashboardMapper.getPlanTypeNumList());
        zxDashboard.setPlanBoardViewList(zxDashboardMapper.getPlanBoardViewList());
        zxDashboard.setTaskDailyList(zxDashboardMapper.getTaskDailyList());
        zxDashboard.setPlanNearList(zxDashboardMapper.getPlanNearList());
        zxDashboard.setTaskTodayList(zxDashboardMapper.getTaskTodayList());
        return zxDashboard;
    }
}
